package com.hntest.controller;

import com.hntest.entity.Account;
import com.hntest.entity.LoginInfo;
import com.hntest.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller("personController")
public class PersonController {

    @Autowired
    private PersonService personService;
    public  void  setPersonService(PersonService personService){
        this.personService=personService;
    }

    @RequestMapping(value="/doPerson",method= {RequestMethod.POST,RequestMethod.GET})
    public String doPerson(Integer id, HttpServletRequest request) {
        HttpSession session=request.getSession(true);
        LoginInfo currUser = (LoginInfo) session.getAttribute("currUser");
        Account account=personService.selectAccount(currUser.getLid());
        System.out.println(account.toString());
        request.setAttribute("account", account);
        return "person_info";
    }
}
